home *** CD-ROM | disk | FTP | other *** search
- /* Handle a Retrieve request from a WWW client HTRetrieve.c
- ** ===========================================
- **
- ** Authors
- ** CTB Carl Barker, Brunel
- ** DMX Daniel Martin
- ** TBL Tim Berners-Lee, CERN, Geneva timbl@info.cern.ch
- **
- ** History:
- ** 29 Apr 91 (TBL) Split from daemon.c
- ** 5 Sept 91 (DMX) Added path simplification to prevent '..'ing to an
- ** uncorrect directory.
- ** Added '\r' as space for telneting to socket.
- ** 10 Sep 91 (TBL) Reject request and log if fails authorisation
- ** 26 Jan 92 (TBL) Added some of CTB's code for directory read.
- ** 23 Ap 93 (TBL) keyword untangling passed to lower level
- */
-
- /* (c) CERN WorldWideWeb project 1990,91. See Copyright.html for details */
-
- #define USE_PLAINTEXT /* Makes retrieval of postscript easier for now */
- /* but not good sgml */
-
- #define BUFFER_SIZE 4096 /* Arbitrary size for efficiency */
- #define INFINITY 512 /* file name length @@ FIXME */
-
- #include "HTUtils.h"
- #include "HTFormat.h"
- #include "tcp.h"
-
- #ifdef RULES /* Use rules? */
- #include "HTRules.h"
- #endif
- #include "HTParse.h"
-
- #include "HTFile.h"
- #include "HTDaemon.h" /* calls back to HTTP daemon */
- #include "HTMLGen.h" /* For HTML generator */
- #include "HTWriter.h" /* For making streams to net and disk */
-
- #include "HTAccess.h"
-
- extern int WWW_TraceFlag; /* Control diagnostic output */
- extern FILE * logfile; /* Log file output */
- /* extern char HTClientHost[16]; */ /* Client name to be output */
- extern int HTWriteASCII PARAMS((int soc, char * s)); /* In HTDaemon.c */
-
- /* PUBLIC FILE * logfile = 0; */ /* Log file if any */
- extern char *HTClientHost; /* Peer internet address */
-
-
-
-
-
- /* Override HTML presentation method
- ** ---------------------------------
- **
- ** The "presentation" of HTML in the case of a server is
- ** the generation of HTML markup. The presence of this
- ** routine prevents any of the client-oriented presentation code
- ** from being picked up from the library libwww.
- */
- PUBLIC HTStructured* HTML_new ARGS3(
- HTParentAnchor *, anchor,
- HTFormat, format_out,
- HTStream*, stream)
- {
- HTStream * markup = HTStreamStack(
- WWW_HTML, format_out, stream, anchor);
- if (!markup) return NULL;
-
- return HTMLGenerator(markup);
- }
-
-
- /* Dummy things in hypertext object @@@@ */
-
- PUBLIC void HText_select() {}
- PUBLIC void HText_selectAnchor() {}
- PUBLIC void * HTMainAnchor = NULL;
-
-
-
- /* Retrieve a document
- ** -------------------
- */
- #ifdef __STDC__
- int HTRetrieve(const char * arg, int soc)
- #else
- int HTRetrieve(arg, soc)
- char *arg;
- int soc;
- #endif
- {
-
- char * arg2 = 0; /* Simplified argument */
- char * keywords=strchr(arg, '?');
-
- #ifdef NOSEARCH
- if (keywords) {
- *keywords++ = 0; /* Chop keywords off */
- if (!*keywords) keywords = NULL;
- else {
- char *p;
- for (p=keywords; *p; p++) if (*p == '+') *p = ' ';
- /* Plusses to spaces */
- HTUnEscape(keywords);
- }
- }
-
- if (keywords) {
- if (TRACE) printf("HTHandle: can't perform search %s\n",
- arg);
- return HTLoadError(HTASCIIWriter(soc), 403,
- "Sorry, this server does not perform searches.");
- /* It ought to, using an executable script */
- }
- #endif
-
- StrAllocCopy(arg2, arg);
- HTSimplify(arg2); /* Remove ".." etc (DMX) */
-
-
- /* Load the document into the client
- */
- {
- HTStream * client = HTASCIIWriter(soc);
-
- HTLoadToStream(arg2, NO, client);
- free(arg2);
- return HT_LOADED;
- }
-
- } /* Retrieve */
-
-
-